Skip to content

Conversation

@elliott-with-the-longest-name-on-github
Copy link
Contributor

@elliott-with-the-longest-name-on-github elliott-with-the-longest-name-on-github commented Nov 13, 2025

  • Make tests (really strugglin' on this)
  • Make docs

Before submitting the PR, please make sure you do the following

  • It's really useful if your PR references an issue where it is discussed ahead of time. In many cases, features are absent for a reason. For large changes, please create an RFC: https://github.com/sveltejs/rfcs
  • Prefix your PR title with feat:, fix:, chore:, or docs:.
  • This message body should clearly illustrate what problems it solves.
  • Ideally, include a test that fails without this PR but passes with it.
  • If this PR changes code within packages/svelte/src, add a changeset (npx changeset).

Tests and linting

  • Run the tests with pnpm test and lint the project with pnpm lint

@changeset-bot
Copy link

changeset-bot bot commented Nov 13, 2025

🦋 Changeset detected

Latest commit: bc9df88

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
svelte Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@svelte-docs-bot
Copy link

@github-actions
Copy link
Contributor

Playground

pnpm add https://pkg.pr.new/svelte@17154

Comment on lines +33 to +35
isomorphic_hydratable['get'] = get_hydratable_value;
isomorphic_hydratable['has'] = has_hydratable_value;
isomorphic_hydratable['set'] = () => e.fn_unavailable_on_client('hydratable.set');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not at all convinced we need these — can we get rid of them?

Comment on lines +653 to +662
return `
<script>
{
const store = (window.__svelte ??= {}).h ??= new Map();
for (const [k,v] of [${entries.join(',')}]) {
store.set(k, v);
}
}
</script>`;
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

as a purely aesthetic matter it would be nice if this was indented in a way that looks sensible when you view source

Suggested change
return `
<script>
{
const store = (window.__svelte ??= {}).h ??= new Map();
for (const [k,v] of [${entries.join(',')}]) {
store.set(k, v);
}
}
</script>`;
}
return `
<script>
{
const store = (window.__svelte ??= {}).h ??= new Map();
for (const [k,v] of [${entries.join(',')}]) {
store.set(k, v);
}
}
</script>`;
}

}
}

export class MemoizedUneval {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we really need this? Typically, each hydratable value would be different. And they will hydrate to different objects, even if they do in fact refer to the same object, because we're not unevaling everything at one (and can't, because of custom encode/decode logic). It seems like overhead

* @template T
* @param {string} key
* @param {() => T} fn
* @param {{ transport?: Transport<T> }} [options]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I still think the third argument should probably be the transport options, unless we actually expect to add other options in future

const store = get_render_context();

if (store.hydratables.has(key)) {
e.hydratable_clobbering(key, store.hydratables.get(key)?.stack || 'unknown');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I find myself wondering if we should just allow this — we can serialize the second value, and warn if there's a mismatch (i.e. the second serialization differs from the first) but otherwise just re-use the first value? If I have a (possibly library-provided) function that uses hydratable internally, it could be annoying to have to refactor my code to ensure that I only call it in one component rather than two.

Counter-argument: without also providing the ability to cache/dedupe, this could result in work (such as an API request/whatever) being done twice.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants